Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SQLite, account creation, and account fetching #16

Merged
merged 6 commits into from
Apr 23, 2024
Merged

Conversation

dguenther
Copy link
Member

@dguenther dguenther commented Apr 22, 2024

Changes

  • Adds SQLite using Kysely
  • Adds a DatabaseLoader component to _layout.tsx that runs an initialization migration (like in the node app)
  • Updates data-facade to pass through mutation options to allow clearing the query cache after a mutation
  • Adds account handlers that use SQLite. The old handlers with test data are now in the same folder called demoHandlers (I'm down to restructure these to something different)

Fixes IFL-2422

Comment on lines +11 to +16
const createAccount = facade.createAccount.useMutation({
onSuccess: () => {
qc.invalidateQueries({
queryKey: ['getAccounts']
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: IIRC, it's possible to set a default for this with React Query. I'd recommend busting the whole cache on mutation. IMO, being overly aggressive with cache busting after a mutation is usually the way to go; especially for stuff like accounts that will be on-device, so the request doesn't even need to go over the wire.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in the node app, we handle this at the trpc-react level: https://github.com/iron-fish/ironfish-node-app/blob/9712ebf2cd64507b42b8a055ab9efebc9a808f6d/renderer/providers/TRPCProvider.tsx#L14

So I think we'd need to add something to data-facade to allow for this? We can pass defaultOptions to the QueryClient to set onSuccess by default, but it would get clobbered if we wanted to set onSuccess on mutations explicitly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to kick this down the road and add a ticket in Linear for it: https://linear.app/if-labs/issue/IFL-2522/invalidate-react-query-query-cache-on-all-mutations

@dguenther dguenther merged commit 5401f5f into main Apr 23, 2024
1 check passed
@dguenther dguenther deleted the sqlite branch April 23, 2024 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants